package warmachinesystem.provider;

import java.util.Collection;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationWrapper;
import org.eclipse.emf.ecore.EStructuralFeature;

import warmachinesystem.ArmyList;
import warmachinesystem.WarmachineSystemFactory;
import warmachinesystem.WarmachineSystemPackage;

public class WarcasterGroupItemProvider extends TransientArmyListItemProvider {

	public WarcasterGroupItemProvider(AdapterFactory adapterFactory,
			ArmyList armyList) {
		super(adapterFactory, armyList);
	}

	/**
	 * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
	 * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
	 * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
		if (childrenFeatures == null) {
			super.getChildrenFeatures(object);
			childrenFeatures.add(WarmachineSystemPackage.Literals.ARMY_LIST__BASE_UNITS);
		}
		return childrenFeatures;
	}

	public String getText(Object object) {
		return "Warcasters";
	}

	public void notifyChanged(Notification notification) {
		switch (notification.getFeatureID(ArmyList.class)) {
		case WarmachineSystemPackage.ARMY_LIST__BASE_UNITS:
			fireNotifyChanged(new NotificationWrapper(this, notification));
			return;
		}
	}

	protected void collectNewChildDescriptors(
			Collection<Object> newChildDescriptors, Object object) {
		super.collectNewChildDescriptors(newChildDescriptors, object);
		newChildDescriptors.add(createChildParameter(
				WarmachineSystemPackage.Literals.ARMY_LIST__BASE_UNITS,
				WarmachineSystemFactory.eINSTANCE.createWarcaster()));

	}

	@Override
	public Collection<?> getChildren(Object object) {
		ArmyList parent = (ArmyList) super.getParent(object);
		return parent.getWarcasters();
	}
	
}
